package com.xuzhen.designPattern.observer.one;

import java.util.ArrayList;

public class Dog implements Subject {
	private ArrayList<Observer> obs;
	
	public Dog(){
		this.obs=new ArrayList<Observer>();
	}
	
	@Override
	public void notifyObserver() {
		for(int i=0;i<obs.size();i++){
			obs.get(i).dispaly();
		}
	}

	@Override
	public void registerObserver(Observer o) {
		obs.add(o);
	}

	@Override
	public void removeObserver(Observer o) {
		int i=obs.indexOf(o);
		if(i>=0){
			obs.remove(o);
		}
	}
	
	public void barking (){
		System.out.println("狗叫了......");
	    notifyObserver();
	}

}
